package com.example.interview.example.bankCallSystem.impl_3;

import java.util.ArrayList;
import java.util.List;

public class WindowList {
    public List<WindowForNormal> normallist = new ArrayList<>();
    public List<WindowForVIP> viplist = new ArrayList<>();
    public List<WindowForQuick> quicklist = new ArrayList<>();
    public WindowList() { //初始化1~6号窗口
        for (int i = 1; i < 5; i++) {
            normallist.add(new WindowForNormal(i));  //1~4号窗口为Normal窗口
            quicklist.add(new WindowForQuick(5));   //5号窗口为Quick窗口
            viplist.add(new WindowForVIP(6));       //6号窗口为VIP窗口
        }
    }

    public Window getIdelVIPWindow() {//获取一个空闲的VIP窗口
        for (Window s : viplist) {
            if (!s.isBusy) {
                return s;
            }
        }
        return null;
    }
    public Window getIdelNormalWindow() {//获取一个空闲的Normal窗口
        for (Window s : normallist) {
            if (!s.isBusy) {
                return s;
            }
        }
        return null;
    }

    public Window getIdelQuickWindow() { //获取一个空闲的Quick窗口
        for (Window s : quicklist) {
            if (!s.isBusy) {
                return s;
            }
        }
        return null;
    }


    class WindowForVIP extends Window {//定义空闲的VIP窗口对象
        public WindowForVIP(int i) {
            id = i;
            type = "vip";
            isBusy = false;
        }
    }
    class WindowForNormal extends Window {//定义空闲的Normal窗口对象
        public WindowForNormal(int i) {
            id = i;
            type = "normal";
            isBusy = false;
        }
    }
    class WindowForQuick extends Window {//定义空闲的Quick窗口对象
        public WindowForQuick(int i) {
            id = i;
            type = "quick";
            isBusy = false;
        }
    }

}
